import axios from "@/utils/http";
//数据
const state = {
  //数据定义处
  doctorData:[],
  tableTotal:1,
  keshiData:[]
};

const getters = {
  //修饰后的数据获取方法
  // getXXX(state:any){
  //   return state.XXX
  // }
  getDoctor(state:any,id:any){
      let arr = state.doctorData;
      console.log(arr);
      
      return arr
  }
};

const mutations = {
  //修改数据处 ，可在这写axios请求拿数据
  setDoctorData(state:any,str:any){
    axios({
      url:"/setting/doctorManage/findEmpList",
      method:"get",
      params:{
        
        currentPage:str.currentPage,
          pageSize:str.pageSize,
      }
      }).then((res:any)=>{
          state.doctorData=res.data.data
          state.tableTotal=res.data.count
     }).catch(err=>{
      console.log(err);
     })
    
  },
  setKeshiData(state:any,str:any){
    axios({
      url:"/setting/officeManage/findOfficeList",
      method:"get",
      params:{
        
      }
      }).then((res:any)=>{
          state.keshiData=res.data.data
     }).catch(err=>{
      console.log(err);
     })
    
  },

  
  searchDoctorData(state: any, row: any){
    console.log(row);
  
    axios({
      url:"/setting/doctorManage/findEmpByEmpName",
        method:"get",
        params:{
          empName:row.empName,
          currentPage:row.currentPage,
            pageSize:row.pageSize,
        },
    }).then((res:any)=>{
      console.log("1", res);
      state.doctorData=res.data.data
    });
  }
  // addDoctorData(state:any,todo:any){
  //   let arr=JSON.parse(JSON.stringify(todo .value))
  //   arr.forEach((form:any) => {
  //      axios({
  //     url:"/setting/doctorManage/addEmp",
  //     method:"get",
  //     params:{
  //       empName:form.empName,
  //       officeId:form.officeId,
  //       empGrade:form.empGrade,
  //       empPhoneNum:form.empPhoneNum,
  //       empAge:form.empAge,
  //       menuId:form.menuId,
  //     }
  //     }).then((res:any)=>{
  //         state.doctorData=res.data.data
  //    }).catch(err=>{
  //     console.log(err);
  //    })
  //   });
   
  // }
};

const actions = {};

export default {
  state,
  mutations,
  actions,
  getters,
};
